package cn.craftyun.serverlist.config;

import cn.craftyun.serverlist.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvcConfig
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * 配置拦截器
     *
     * @param registry InterceptorRegistry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor())
                .addPathPatterns("/api/user/**")
                .addPathPatterns("/api/server/**")
                .excludePathPatterns("/api/user/login")
                .excludePathPatterns("/api/user/reg")
                .excludePathPatterns("/api/server/get/*")
                .excludePathPatterns("/api/server/list");
    }
}
